import Vue from "vue"
import VueRouter from "vue-router"
import Layout from "../views/Layout"
import Login from "../views/Login/Login.vue"
import Home from "../views/Home/index.vue"

const Goods = () => import("../views/Goods/Goods.vue")
const AddOrder = () => import("../views/Order/AddOrder.vue")
const User = () => import("../views/User/index.vue")
const Order = () => import("../views/Order/index.vue")
const Params = () => import("../views/Params/Params.vue")
const Specifications = () =>
  import("../views/Params/ParamsInfo/Specifications.vue")

Vue.use(VueRouter)

const routes = [
  {
    path: "",
    component: Layout,
    meta: {
      isLoagin: true,
    },
    children: [
      {
        path: "/",
        name: "Home",
        component: Home,
      },
      {
        path: "goods",
        name: "Goods",
        component: Goods,
      },
      {
        path: "add-orders",
        name: "AddOrder",
        component: AddOrder,
      },
      {
        path: "user",
        name: "User",
        component: User,
      },
      {
        path: "params",
        name: "Params",
        component: Params,
        redirect: "/params/specifications",
        children: [
          {
            path: "specifications",
            name: "specifications",
            component: Specifications,
          },
        ],
      },
      {
        path: "order",
        name: "Order",
        component: Order,
      },
    ],
  },
  {
    path: "/login",
    name: "Login",
    component: Login,
  },
]

const router = new VueRouter({
  routes,
})

export default router
